//引入获取三级分类列表的ajax请求
import {
    reqCategoryList
} from "@/api"
// 引入获取三级分类列表常量
import {
    SET_CATEGORYLIST
} from "../constant-type"

const state = {
    categoryList: []
}
// 设置三级分类列表
const mutations = {
    [SET_CATEGORYLIST](state, payload) {
        state.categoryList = payload.categoryList
    }
}
// 获取三级分类列表
const actions = {
    async getCategoryListAsync({
        commit
    }) {
        try {
            const result = await reqCategoryList()
            commit(SET_CATEGORYLIST, {
                categoryList: result
            })
        } catch (error) {
            alert(error.message)
        }
    }
}
const getters = {}


export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}